package com.franklions.nacos.example.service;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import org.springframework.stereotype.Service;

/**
 * @author flsh
 * @version 1.0
 * @date 2023/4/6
 * @since Jdk 1.8
 */
@Service
public class ConfigServiceDemo {

    @NacosInjected
    private ConfigService configService;

    public String demoGetConfig(String dataId,String groupId) {
        try {
            String content = configService.getConfig(dataId, groupId, 5000);
            System.out.println(content);
            return content;
        } catch (NacosException e) {
            e.printStackTrace();
        }
        return null;
    }
}
